import request from "@/utils/request"; // 导入封装请求的js文件

// 获取我的订单列表
export function getOrderList(params) {
  return request({
    url: "/omsOrder/me",
    method: "post",
    data: params,
  });
}
// 更新订单等级和备忘录
export function editOrderLevel(params) {
  return request({
    url: "/omsOrder/level",
    method: "put",
    data: params,
  });
}
// 订单详情
export function getOrderDetail(id) {
  return request({
    url: `/omsOrder/one/${id}`,
    method: "get",
  });
}
// 更新订单的状态
export function editOrderStatus(params) {
  return request({
    url: "/omsOrder/status",
    method: "put",
    data: params,
  });
}
// 订单导出功能
export function orderDownd(param) {
  return request({
    url: "/omsOrder/export",
    method: "post",
    data: param,
    responseType: "blob", // 必填项
    headers: {
      responseType: "blob",
    },
  });
}

//

// 获取所有店铺
export function selectStoreNAmByParams(params) {
  return request({
    url: "/omsOrder/selectStoreNAmByParams",
    method: "get",
    params: params,
  });
}
// 获取所有售后订单
export function getSelectAllByParams(data) {
  return request({
    url: "/omsOrderReturnApply/selectAllByParams",
    method: "post",
    data
  });
}

export function fetchOrderDetail(id) {
  return request({
    url: `/omsOrderItem/${id}`,
    method: "get",
  });
}

export function fetchRefundDetail(id) {
  return request({
    url: `/omsOrderReturnApply/${id}`,
    method: "get",
  });
}

export function postRefund(data) {
  return request({
    url: "/omsOrderReturnApply/create",
    method: "post",
    data,
  });
}

export function postModifyRefund(data) {
  return request({
    url: "/omsOrderReturnApply/updateOrderReturn",
    method: "put",
    data,
  });
}

export function postDeleteRefund(id) {
  return request({
    url: `/omsOrderReturnApply/removeOrderReturn`,
    method: "delete",
    params: { id },
  });
}

export function postSubmitRefundGoods(data) {
  return request({
    url: `/omsOrderReturnApply/OrderReturnGoods`,
    method: "post",
    data,
  });
}

export function fetchExpressList(id) {
  return request({
    url: "/kuaidi100/findOrder?id=" + id,
    method: "get",
  });
}

export function postReceiveGoods(id) {
  return request({
    url: `/omsOrderReturnApply/confirmReceipt?id=${id}`,
    method: "post",
  });
}

export function fetchExpressCompanyList() {
  return request({
    url: "/omsOrderExpress",
    method: "get",
  });
}

export function fetchBusinessAddress(productId) {
  return request({
    url: "/omsOrderReturnApply/getStoreDetail",
    method: "get",
    params: {
      productId,
    },
  });
}

export function postCloseOrder(id) {
  return request({
    url: `/omsOrder/closeOrder?orderId=${id}`,
    method: "post",
  });
}
